from utils.network import UpgradeInterface
from utils import memory


class API(UpgradeInterface):

    def handle(self, req):
        file_id = req['file_id']
        f = open(memory.files[file_id]['file_path'], 'rb')
        while True:
            data = f.read(100000)
            if len(data) == 0:
                break
            self._conn.send(data)
        f.close()
